package com.caizi.base.utils;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * @Author 菜菜籽
 * @Date 2024-10-16 9:10
 * @description: 文件相关操作
 */
public class FileUtil {

    //确保某个文件夹是否存在，如果不存在则创建
    public static Integer ensureDirectoryExists(String directoryPath) {
        Path path = Paths.get(directoryPath);
        if (!Files.exists(path)) {
            try {
                Files.createDirectories(path);
                return 1;
            } catch (IOException e) {
                return 0;
            }
        } else {
            return 1;
        }
    }
}
